
package interface_grafica;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import listeners.ListenersTelaConsultaSocio;

public class TelaConsultaSocio extends javax.swing.JPanel {

    private static TelaConsultaSocio instance;

    public static TelaConsultaSocio getInstance() {
        if (instance == null) {
            instance = new TelaConsultaSocio();
        }
        return instance;
    }     
    
    public TelaConsultaSocio() {
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        opcaoSexo = new javax.swing.ButtonGroup();
        jLabel6 = new javax.swing.JLabel();
        tipoBuscaSocio = new javax.swing.JComboBox();
        campoBuscaSocio = new javax.swing.JTextField();
        botaoBuscaSocio = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabelaSocios = new javax.swing.JTable();
        btCancelar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        setPreferredSize(new java.awt.Dimension(1063, 557));

        jLabel6.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
        jLabel6.setText("Filtrar por");

        tipoBuscaSocio.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
        tipoBuscaSocio.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ID", "CPF", "Rua" }));

        campoBuscaSocio.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N

        botaoBuscaSocio.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
        botaoBuscaSocio.setText("Pesquisar");

        tabelaSocios.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
        tabelaSocios.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null}
            },
            new String [] {
                "ID", "Nome", "Tipo de socio"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
                
        tabelaSocios.getSelectionModel().addListSelectionListener(new ListenersTelaConsultaSocio());  
                
        jScrollPane1.setViewportView(tabelaSocios);

        btCancelar.setText("Cancelar");

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel1.setText("Consulta de Socios");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btCancelar)
                .addGap(78, 78, 78))
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(89, 89, 89)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel6)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(tipoBuscaSocio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoBuscaSocio)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(botaoBuscaSocio))
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 820, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(429, 429, 429)
                        .addComponent(jLabel1)))
                .addContainerGap(154, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(34, 34, 34)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 100, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(tipoBuscaSocio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(botaoBuscaSocio)
                    .addComponent(campoBuscaSocio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 294, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(10, 10, 10)
                .addComponent(btCancelar)
                .addGap(43, 43, 43))
        );
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botaoBuscaSocio;
    private javax.swing.JButton btCancelar;
    private javax.swing.JTextField campoBuscaSocio;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.ButtonGroup opcaoSexo;
    private javax.swing.JTable tabelaSocios;
    private javax.swing.JComboBox tipoBuscaSocio;
    // End of variables declaration//GEN-END:variables

    public JButton getBotaoBuscaSocio() {
        return botaoBuscaSocio;
    }

    public JButton getBtCancelar() {
        return btCancelar;
    }

    public String getCampoBuscaSocio() {
        return campoBuscaSocio.getText();
    }

    public ButtonGroup getOpcaoSexo() {
        return opcaoSexo;
    }

    public JTable getTabelaSocios() {
        return tabelaSocios;
    }

    public JComboBox getTipoBuscaSocio() {
        return tipoBuscaSocio;
    }
    
    public DefaultTableModel getDtm() {

		DefaultTableModel dtm = (DefaultTableModel) tabelaSocios.getModel();

		return dtm;
	}
    
   public void limpaDtm(){		
		getDtm().setNumRows(0);
	}
   	
}




